package exam.wangyi.spring.S2;

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        System.out.println(getMaxSore(s));
    }

    public static long getMaxSore(String s) {
        long[] score = new long[s.length()];
        boolean[] mark = new boolean[s.length()];
        if (s.length() < 2)
            return 0;
        if (isMarkable(s, 0)) {
            score[1] = getScore(s, 0) + getScore(s, 1);
            mark[0] = true;
            mark[1] = true;
        }
        for (int i=2; i<s.length(); ++i) {
            if (!mark[i-1]) {
                if (isMarkable(s, i-1)) {
                    mark[i-1] = true;
                    mark[i] = true;
                    score[i] = score[i-1] + getScore(s, i-1) + getScore(s, i);
                } else {
                    score[i] = score[i-1];
                }
            } else {
                if (isMarkable(s, i-1)) {
                    long s1 = getScore(s, i-2), s2 = getScore(s, i);
                    if (s2 > s1) {
                        mark[i-2] = false;
                        mark[i] = true;
                        score[i] = score[i-1] - s1 + s2;
                    } else {
                        score[i] = score[i-1];
                    }
                } else {
                    score[i] = score[i-1];
                }
            }
        }
        return score[s.length()-1];
    }

    public static boolean isMarkable(String s, int i) {
        return Math.abs(s.charAt(i)-s.charAt(i+1)) < 2;
    }

    public static long getScore(String s, int i) {
        return s.charAt(i)-'a'+1L;
    }
}